//
//  EndTeachingViewController.m
//  MM
//
//  Created by 郑渊文 on 6/3/15.
//  Copyright (c) 2015 王晨辉. All rights reserved.
//

#import "EndTeachingViewController.h"
#import "SummaryViewController.h"


@interface EndTeachingViewController ()

{
    UIButton *backBtn;
    UIView *myBgView;
}
@property(nonatomic,copy)NSString *DetailText;
@end

@implementation EndTeachingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSDictionary *param4 = @{@"classId":_classId};
    
    [UserDAL getClassdetailParams:param4 withBlock:^(NSDictionary *data, NSError *error) {
        if (data) {
            ////NSLog(@"what%@",data);
           _DetailText = data[@"classIntroduce"];
//            for (NSDictionary *mydic in array) {
//                
//            }
        
            
        }else
        {
            
        }
    }];
    _DetailText= @"Acting as if nothing borne in mind is the best revenge.It's all for myself to live better.Every day may not be good…but there's something good in every day.Happiness is about having each tiny wish come ture.A woman has got to love a bad man once or twice in her life to be thankful for a good one.";
    
    [self initSubViews];
    self.navigationItem.title = @"课程详情";
    [self.navigationController.navigationBar setTranslucent:NO];//设置navigationbar的半透明
    [self.navigationController.navigationBar setBarTintColor:[GetFileModel colorWithHexString:@"#34bd81" alpha:1]];
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,nil]];

    //    self.navigationItem.rightBarButtonItem.title = @"课程详情";
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


-(void)initSubViews
{

    
    
    if (IS_IPHONE_4_OR_LESS) {
        UIScrollView *bgView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
        bgView.contentSize = CGSizeMake(SCREEN_WIDTH, 568);
        bgView.backgroundColor = [UIColor whiteColor];
        [self.view addSubview:bgView];
        myBgView = bgView;
    }
    else
    {
        
        UIView *bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
        bgView.backgroundColor = [UIColor whiteColor];
        [self.view addSubview:bgView];
        myBgView = bgView;
    }
    //自定义左右按钮
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button setBackgroundImage:[UIImage imageNamed:@"_0000_返回.png"]
     
                      forState:UIControlStateNormal];
    
    [button addTarget:self action:@selector(back)
     
     forControlEvents:UIControlEventTouchUpInside];
    
    button.frame = CGRectMake(0, 0, 20, 15);
    
    
    
    UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
    
    
    
    self.navigationItem.leftBarButtonItem = menuButton;
    
    
//    
//    UIView *bgView = [[UIView alloc]initWithFrame:CGRectMake(0,0, SCREEN_WIDTH, SCREEN_HEIGHT)];
//    [self.view addSubview:bgView];
    myBgView.backgroundColor = [UIColor whiteColor];
    
    UILabel *intrTitle = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2-100, 10, 200, 60)];
    intrTitle.text = @"课程介绍";
    intrTitle.textAlignment = NSTextAlignmentCenter;
    intrTitle.font  = [UIFont systemFontOfSize:25];
    intrTitle.textColor = [UIColor blackColor];
    [myBgView addSubview:intrTitle];
    
    UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 70, SCREEN_WIDTH, 1)];
    lineView.backgroundColor = UIColorWithRGBA(215, 215, 215, 1);
    [myBgView addSubview:lineView];
    
    UILabel *introduceLable = [[UILabel alloc]initWithFrame:CGRectMake(10, 220, SCREEN_WIDTH-20, 60)];
    introduceLable.numberOfLines = 0;
    introduceLable.font = [UIFont fontWithName:@"Helvetica" size:13];
    
    NSString *text = _DetailText;
    
    
    UIFont *font = [UIFont fontWithName:@"Helvetica" size:13.0];
    CGSize size = [text sizeWithFont:font constrainedToSize:CGSizeMake(SCREEN_WIDTH-20, 2000.0f)
                       lineBreakMode:NSLineBreakByWordWrapping];
    CGRect rect = introduceLable.frame;
    rect.size = size;
    float viewHeight = size.height;
    [introduceLable setFrame:rect];
    [introduceLable setText:text];
    
    UIImageView *lessionImg = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, SCREEN_WIDTH-40, 200)];
    lessionImg.backgroundColor = [UIColor redColor];
    
    
    UIView *introduceView = [[UIView alloc]initWithFrame:CGRectMake(10, 80, SCREEN_WIDTH-20, 40+viewHeight+200)];
    introduceView.backgroundColor = [UIColor whiteColor];
    introduceView.layer.borderColor = [UIColor clearColor].CGColor;
    introduceView.backgroundColor = [UIColor whiteColor];
    introduceView.layer.borderWidth = 1;
    
    [myBgView addSubview:introduceView];
    [introduceView addSubview:introduceLable];
    [introduceView addSubview:lessionImg];
    
    
    
    UIButton *myBtn = [[UIButton alloc]initWithFrame:CGRectMake(50, SCREEN_HEIGHT-120, SCREEN_WIDTH-100, 40)];
    [myBtn setBackgroundImage:[UIImage imageNamed:@"确认上课结束"] forState:UIControlStateNormal];
    [myBtn addTarget:self action:@selector(makeSureEnding) forControlEvents:UIControlEventTouchUpInside];
    [myBgView addSubview:myBtn];
    
}

-(void)makeSureEnding
{
    SummaryViewController *setVC = [[SummaryViewController alloc]init];
    setVC.classId = self.classId;
    UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:setVC];
    [self  presentViewController:nav animated:YES completion:nil];
    
}

-(void)back
{
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}

@end
